import React from 'react'
import {useLocation}  from 'react-router-dom'
import qs from 'qs'

export default function Music() {
  /* 
    useLocation:可以获取当前的路由地址信息
      - path：当前的路由地址
      - search：查询字符串形式的路由传参
  */
  const location = useLocation();
  // console.log(location);
  const {name , age} = qs.parse(location.search.split("?")[1])
  console.log(name , age);

  return (
    <div>
      <h3>姓名:{name}</h3>
      <h3>年龄:{age}</h3>
    </div>
  )
}
